package com.and.listviewdemo1;

import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.GridView;
import android.widget.Toast;

public class ListViewDemo1Activity extends Activity {
    /** Called when the activity is first created. */
	
	GridView gridView;
	ListAdapter adapter;
	ArrayList<Item> listItem;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        String sdPath = Environment.getExternalStorageDirectory()+"";
        String imgPath = sdPath +"\\" +"baivuanghe.jpg";
        listItem = new ArrayList<Item>();
        
        
    /*    int id = R.drawable.tatca;
        String strID = id +""; */
        listItem.add(new Item(R.drawable.tatca + "", "Tất Cả"));
        listItem.add(new Item(R.drawable.nghenhieunhat + "", "Nghe Nhiều Nhất"));
        listItem.add(new Item(R.drawable.baivuanghe+"", "Bài vừa nghe"));
        listItem.add(new Item(R.drawable.themganday+"", "Thêm Gần Đây"));
        listItem.add(new Item(R.drawable.hotlist+"", "Hot List"));
    
     
        
        adapter = new ListAdapter(getApplicationContext(), listItem);      
        gridView = (GridView)findViewById(R.id.gridView1);
        gridView.setAdapter(adapter);  
        
        
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
    	MenuInflater menuInflater = getMenuInflater();
    	menuInflater.inflate(R.menu.menu1, menu);
    	return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    	    {
    	 
    	        switch (item.getItemId())
    	        {
    	        case R.id.menu_add:
    	         
    	            Toast.makeText(ListViewDemo1Activity.this, "Add", Toast.LENGTH_SHORT).show();
    	            return true;
    	 
    	        case R.id.menu_search:
       	         
    	            Toast.makeText(ListViewDemo1Activity.this, "Search", Toast.LENGTH_SHORT).show();
    	            return true;
	 
    	        case R.id.menu_delete:
          	         
    	            Toast.makeText(ListViewDemo1Activity.this, "Delete", Toast.LENGTH_SHORT).show();
    	            return true;
     
    	        case R.id.menu_setting:      	         
    	            Toast.makeText(ListViewDemo1Activity.this, "Setting", Toast.LENGTH_SHORT).show();
    	            return true;  	 
    	        default:
   	            return super.onOptionsItemSelected(item);
   	        }
    	    }    
}